Given /^I have not created a wishlist$/ do
  #creates the wish list call "test list"
  @browser.goto("https://secure.newegg.com/WishList/WishListCurrent.aspx")
  @browser.text_field(:id, "WishListTitle").set "test list"
  @browser.link(:href, "javascript:Biz.WishList.MySave.addNewTitle('new');").click
end

Then /^I want to go to an item and add it to my created wish list$/ do
  #gets the product ids and puts them in an array. 1 siginifies the column to get them from.
  product = sp.getColumn(1)  
  for i in 0..product.size
    @browser.goto("http://www.newegg.com/Product/Product.aspx?Item=#{product[i]}")
    @browser.goto("http://secure.newegg.com/WishList/WishCartPlus.aspx?Submit=ADDITEM2WISHLIST&Item=#{product[i]}&qty=1")
  end
  #moves all all products from the temp wish list to the "test list"
  @browser.checkbox(:id, "chkSelectAllNone").set
  @browser.select_list(:name, "SelectWishList").select("test list")
  @browser.link(:href, "javascript:Biz.WishList.Common.addtoWishList('WishListForm','chkItems','SAVEEXISTWISHLIST');").click
end

Given /^that I have items in my wish list$/ do
  @browser.goto("https://secure.newegg.com/WishList/MySavedWishLists.aspx")
  @browser.link(:text, "test list").click
  #checks for an element that will only exist if there are no items in the wish list
  if @browser.div(:class, "contif").exists?
    puts "List Empty"
  end
  
end

Then /^I want to remove an item from my wish list$/ do
  #checks for an element that will only exist if there are no items in the wish list
  if !@browser.div(:class, "contif").exists?
    @browser.checkbox(:id, "chkSelectAllNone").set
    @browser.link(:href, "javascript:Biz.WishList.Common.submitWishList('WishListForm','chkItems','DELETE');").click
  else
    puts "List Empty"
  end
end

And /^I want to view my wish list$/ do
  @browser.goto("https://secure.newegg.com/WishList/WishListCurrent.aspx")
  @browser.link(:text, "test list").click
end